package cn.com.adcc.utils;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.apache.log4j.Logger;

/**
 * Created by anzilu on 2015/10/13.
 */
public class ExtracHandler implements Runnable{

    private static Logger logger = Logger.getLogger(ExtracHandler.class);
    private String source="";
    private String destination="";

    public ExtracHandler(String source,String destination){

        this.source=source;
        this.destination=destination;
    }
    @Override
    public void run() {

        extractFiles();
    }

    public boolean extractFiles(){

        try {
            ZipFile zipFile = new ZipFile(source);
            zipFile.setFileNameCharset("GBK");
            zipFile.extractAll(destination);
            return true;
        }
        catch (ZipException e) {
            logger.error(e.getMessage());
            return false;
        }
    }

    public static void main(String[] args){
        String source="D:\\03-gis.zip";
        String destination="D:\\03-gis";
        ExtracHandler extracHandler=new ExtracHandler(source,destination);
        new Thread(extracHandler).start();
    }
}
